/**
 * Project Name:umale-maintenance
 * File Name:ResumeController
 * Package Name:com.xuhaowei.mvc.jpa.controller
 * Date: 2020/3/14 下午12:29
 * Copyright (c) 2018, Neoglory-umale All Rights Reserved.
 */
package com.xuhaowei.mvc.jpa.controller;

import com.xuhaowei.mvc.jpa.common.ReturnData;
import com.xuhaowei.mvc.jpa.common.ReturnDataUtil;
import com.xuhaowei.mvc.jpa.dao.ResumeDao;
import com.xuhaowei.mvc.jpa.pojo.Resume;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName ResumeController
 * @Description TODO
 * @Author xuhaowei
 * @Date 2020/3/14 下午12:29
 * @Version 1.0.0
 * @since JDK 1.8
 */
@RequestMapping("/resume")
@RestController
public class ResumeController {

    @Autowired
    ResumeDao resumeDao;


    @GetMapping("/resumes/{id}")
    public ReturnData findById(@PathVariable Long id){
        return ReturnDataUtil.success(resumeDao.findOne(id),"");
    }

    @GetMapping("/resumes")
    public ReturnData findAll(){
        return ReturnDataUtil.success(resumeDao.findAll(),"");
    }

    @PutMapping("/resumes")
    public ReturnData update(@RequestBody Resume resume){
        resumeDao.save(resume);
        return ReturnDataUtil.success(resumeDao.findAll(),"");
    }

    @DeleteMapping("/resumes/{id}")
    public ReturnData delete(@PathVariable Long id){
        resumeDao.delete(id);
        return ReturnDataUtil.success(resumeDao.findAll(),"");
    }
}